package com.pruebas.physics.common;

public class SurfaceMapper {
	private float width;
	private float height;
	private float magicNumber;
	
	private float ratio;
	private float magicX;
	private float magicY;
	
	public SurfaceMapper(float width, float height, float magicNumber){
		this.width = width;
		this.height = height;
		this.magicNumber = magicNumber;
		
		this.ratio = this.width / this.height;
		if(this.ratio > 1){
			this.magicX = this.magicNumber * this.ratio;
			this.magicY = this.magicNumber;
		}else{
			this.magicX = this.magicNumber;
			this.magicY = this.magicNumber / this.ratio;
		}
	}
	
	public float[] mapCoordinates(float x, float y){
		float mappedX = x / (this.width / 2) -1;
    	float mappedY = y / (this.height / 2) -1;
    	mappedX *= -this.magicX;
    	mappedY *= -this.magicY;
    	return new float[]{ mappedX, mappedY };
	}
	
	public float getWidth() {
		return width;
	}
	
	public float getHeight() {
		return height;
	}
	
	public float getRatio() {
		return ratio;
	}
	
	public float getMagicX() {
		return magicX;
	}
	
	public float getMagicY() {
		return magicY;
	}
}
